package com.example.groupservice.rabbitmq.publisher;

import lombok.extern.slf4j.Slf4j;
import org.example.entity.constants.Constants;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @Description
 * @Author susu
 * @Date 2024/10/7
 */
@Component
@Slf4j
public class GroupPublisher {
    @Resource
    private RabbitTemplate rabbitTemplate;


    public void groupSendMsg2UserQueue(Object msg){
        rabbitTemplate.convertAndSend(Constants.EXCHANGE_CHAT_TOPIC_NAME,Constants.USER_QUEUE_ROUTING_KEY,msg);
    }

    public void groupSendMsg2ChatDB(Object msg) {
        rabbitTemplate.convertAndSend(Constants.EXCHANGE_CHAT_TOPIC_NAME,Constants.CHATDB_QUEUE_ROUTING_KEY,msg);
    }

    public void groupSendMsg2Chat(Object msg) {
        rabbitTemplate.convertAndSend(Constants.EXCHANGE_CHAT_TOPIC_NAME,Constants.CHAT_QUEUE_ROUTING_KEY,msg);
    }
}
